package com.ask.forMe.controller.ai;

import com.ask.forMe.langchain4j.model.entity.Section;
import com.ask.forMe.langchain4j.rag.splitter.SplitMdByHeadingUtil;
import com.ask.forMe.model.entity.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("quick")
@Tag(name = "测试接口")
public class QuickController {

    @GetMapping
    public Result test(String fileName) throws Exception {
        List<Section> sections = SplitMdByHeadingUtil.splitDocxWithFullHeadingPath(fileName, 250, 3);
        sections.forEach(section -> {
            System.out.println("\n【----------------分段----------------】");
            System.out.println("level: " + section.getLevel());
            System.out.println("titlePath: " + section.getTitlePath());
            System.out.println("content: " + section.getContent());
        });
        return Result.success(sections);
    }
}
